<?php
namespace Admin\Logic;
Class UploadPicLogic {
    public function LoadIgoodimg($picname,$url){
        $image  = new \Think\Image(); 						// 实例化图片处理类
        $localroot = './Public/Widget/webuploader/0.1.5/server/upload2/';
        // 按照原图的比例生成一个最大为100*100的缩略图并保存为'100_'.$picname
        $success = new \Service\OssClient(C('OSS_APPID'),C('OSS_SECRET'),C('OSS_URL'));
        $name=time().rand(10000,99999).".".explode(".",$picname)[1];
        $object1 = $url.$name;
        $filePath1 = $localroot.$picname;
        try{
            $success->uploadFile(C('OSS_BUCKET'), $object1, $filePath1);
            unlink($localroot.$picname);
            $success=null;
            $pic['status']=1;
            $pic['pic'] = 'http://'.C('OSS_URL')."/".$url.$name;
            return $pic;
        }
        catch(OssException $e){
            $pic['status']=2;
            return $pic;
        }
    }
}
?>